<?php
class Auth_Storage_Session
{
	const NAMESPACE_DEFAULT = 'Auth';
	
	const MEMBER_DEFAULT = 'storage';
	
	protected $_session;
	
	protected $_namespace;
	
	protected $_member;
	
    public function __construct($namespace = self::NAMESPACE_DEFAULT, $member = self::MEMBER_DEFAULT)
    {
        $this->_namespace = $namespace;
        $this->_member    = $member;
        $this->_session   = new Zend_Session_Namespace($this->_namespace);
    }
    
    public function getNamespace()
    {
        return $this->_namespace;
    }
    
    public function getMember()
    {
        return $this->_member;
    }
    
    public function isEmpty()
    {
        return !isset($this->_session->{$this->_member});
    }
    
    public function read()
    {
        return $this->_session->{$this->_member};
    }
    
    public function write($contents)
    {
        $this->_session->{$this->_member} = $contents;
    }
    
    public function clear()
    {
        unset($this->_session->{$this->_member});
    }
}
?>